export default {
    state: {
        iscollapse: false,
        tabsList: [
            {
                id:'1',
                path: '/home',
                name: 'home',
                label: '首页',
                icon: 's-home',
            },
        ],
        activityMenu: null
    },
    mutations: {
        //侧边栏的缩放状态
        collapseMenu(state) {
            state.iscollapse = !state.iscollapse
        },

        //改变tab导航状态
        selectMenu(state, val) {
            if (val.name !== 'home') {
                //选中tab的高亮显示
                state.activityMenu = val
                // 添加前需判断tagsList中是否已经存在该val，若有则无需添加
                // 条件判断根据实际的数据结构而来，只需要保证能够准确查找到即可
                const result = state.tabsList.findIndex(item => item.id === val.id)
                if (result === -1) {
                    state.tabsList.push(val)
                }
            } else {
                state.activityMenu = null
            }
        },
        closeTag(state, val) {
            const result = state.tabsList.findIndex(item => item.id === val.id)
            state.tabsList.splice(result, 1)
        },
    }
}